home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 15 / macformat_15.iso / Shareware Internet / Desarrolladores / PlayerPRO 4.5.1 Dev.Kit / MADH Library 4.01 / Libraries / RDriver.h < prev   
Text File  |  1996-02-07  |  14KB  |  435 lines

  1. /********************                        ***********************/
  2. //
  3. //    Player PRO 4.5x -- MAD Music Driver Definition
  4. //
  5. //    Library Version 4.01
  6. //
  7. //    To use with MusicLibrary for Think C & CodeWarrior
  8. //
  9. //    Antoine ROSSET
  10. //    16 Tranchees
  11. //    1206 GENEVA
  12. //    SWITZERLAND
  13. //    
  14. //    FAX:            (+41 22) 346 11 97
  15. //    PHONE:             (+41 89) 203 74 62
  16. //    Compuserve:        100277,164
  17. //    Internet:         rosset@dial.eunet.ch
  18. //
  19. /********************                        ***********************/
  20.  
  21. #ifndef __RDRIVERH__
  22. #define __RDRIVERH__
  23.  
  24. #ifndef __MADH__
  25. #include "MAD.h"
  26. #endif
  27.  
  28. #ifndef __SOUND__
  29. #include <Sound.h>
  30. #endif
  31.  
  32. #ifndef __RETRACE__
  33. #include <Retrace.h>
  34. #endif
  35.  
  36. #if defined(powerc) || defined (__powerc)
  37. #pragma options align=mac68k
  38. #else
  39. #if !defined(THINK_C)
  40. #pragma options align=mac68k
  41. #endif
  42. #endif
  43.  
  44. /********************                        ***********************/
  45. /***                         Define List                            ***/
  46. /********************                        ***********************/
  47.  
  48. #define NUMBER_NOTES        96
  49. #define NOFINETUNE            8363
  50. #define MIN_VOLUME            0
  51. #define MAX_VOLUME            64
  52. #define MAXTRACK            32
  53. #define MAXINSTRU            64
  54. #define    MAXSAMPLE            20
  55. #define MAXPATTERN            200
  56. #define MAXPATTERNSIZE        900
  57. #define MAX_ARP             3
  58.  
  59. /********************                        ***********************/
  60. /***                         Error messages                         ***/
  61. /********************                        ***********************/
  62.  
  63. enum
  64. {
  65.     MADNeedMemory                     = -1,
  66.     MADReadingErr                    = -2,
  67.     MADIncompatibleFile                = -3,
  68.     MADLibraryNotInitialized        = -4,
  69.     MADParametersErr                = -5,
  70.     MADUnknowErr                    = -6,
  71.     MADSoundManagerErr                = -7,
  72.     MADOrderNotImplemented            = -8,
  73.     MADFileNotSupportedByThisPlug    = -9,
  74.     MADCannotFindPlug                = -10
  75. };
  76.  
  77. /********************                        ***********************/
  78. /***                Channel structure definition                    ***/
  79. /********************                        ***********************/
  80.  
  81. struct Channel
  82. {
  83.         long        ID;                    // Channel ID - 0 to 31
  84.  
  85.         Ptr            begPtr;                // Sample Data Ptr - Beginning of data
  86.         Ptr            maxPtr;                // Sample Data Ptr - End of data
  87.         Ptr            curPtr;                // Sample Data Ptr - Current position
  88.         long        sizePtr;            // Sample Size in bytes
  89.         
  90.         long        amp;                // Sample amplitude: 8 or 16 bits
  91.         
  92.         long        loopBeg;            // Loop Beginning
  93.         long        loopSize;            // Loop Size
  94.         
  95.         long        ins;                // Current Instrument ID
  96.         long        insOld;                // Previous Instrument ID played on this channel
  97.         long        samp;                // Current Sample ID
  98.         
  99.         long        fineTune;            // Finetune
  100.         
  101.         long        note;                // Note
  102.         long        noteOld;            // Previous note played on this channel
  103.         
  104.         long         period;                // Current period
  105.         long        periodOld;            // Previous period played on this channel
  106.         
  107.         long        vol;                // Channel vol (0 to 64)
  108.         long         cmd;                // Command
  109.         Byte        arg;                // Argument of command
  110.         Byte        volcmd;                // Volume Command
  111.         
  112.         long         arp[ MAX_ARP];        // Used for arpeggio command
  113.         long         arpindex;            // Used for arpeggio command
  114.         
  115.         long        viboffset;            // Used for vibrato command
  116.         long         vibdepth;            // Used for vibrato command
  117.         long         vibrate;            // Used for vibrato command
  118.         
  119.         long         slide;                // Used for slideUp and slideDown command
  120.         
  121.         long         pitchgoal;            // Used for portamento command
  122.         long         pitchrate;            // Used for portamento command
  123.         
  124.         long         volumerate;            // Used for slideVolume command
  125.         
  126.         long        oldArg[ 16];
  127.  
  128.         Ptr            samplePtr;            // Used internaly by MADPlaySoundData & MADPlaySndHandle
  129.         
  130.         /**/
  131.         
  132.         Boolean        KeyOn;
  133.         short        a;
  134.         short        b;
  135.         short        p;
  136.         long        volEnv;
  137.         long        volFade;
  138.         
  139.         long        lAC;
  140. };
  141. typedef        struct Channel    Channel;
  142.  
  143. /********************                        ***********************/
  144. /***         Music description - used in Import/Export filter    ***/
  145. /********************                        ***********************/
  146.  
  147. struct    MADPartition
  148. {
  149.     MADSpec                    *header;                                // Music Header - See 'MAD.h'
  150.     PatData                    *partition[ MAXPATTERN];                // Patterns
  151.     sData                    *(sample[ MAXINSTRU][ MAXSAMPLE]);        // Instruments
  152. };
  153. typedef        struct MADPartition    MADPartition;
  154.  
  155. /********************                        ***********************/
  156. /***                  Driver Settings definition                    ***/
  157. /********************                        ***********************/
  158.  
  159. enum
  160. {
  161.     ASCSoundDriver = 1,
  162.     AWACSoundDriver,
  163.     MIDISoundDriver,
  164.     SoundManagerDriver,        // You should use only SoundManagerDriver for full compatibility !
  165.     QK21SoundDriver,
  166.     DigiDesignSoundDriver
  167. };
  168.  
  169. enum
  170. {
  171.     MonoOutPut = 1,
  172.     StereoOutPut,
  173.     DeluxeStereoOutPut,
  174.     PolyPhonic                // Do NOT use it ! Standard hardware doesn't support it !
  175. };
  176.  
  177. struct MADDriverSettings
  178. {
  179.     short                    numChn;                                // Active tracks from 2 to 32, automatically setup when a new music is loaded
  180.     short                    outPutBits;                            // 8 or 16 Bits
  181.     unsigned long            outPutRate;                            // Fixed number, by example : rate44khz, rate22050hz, rate22khz, rate11khz, rate11025hz
  182.     short                    outPutMode;                            // MonoOutPut, StereoOutPut or DeluxeStereoOutPut ?
  183.     short                    driverMode;                            // ASCSoundDriver, AWACSoundDriver, MIDISoundDriver or SoundManagerDriver
  184.     Boolean                    antiAliasing;                        // Use AntiAliasing filter ? true/false
  185.     Boolean                    repeatMusic;                        // If music finished, repeat it or stop.
  186.     Boolean                    sysMemory;                            // Allocate memory in Application Heap (false) or in System Heap (true)
  187.     Boolean                    Interpolation;                        // Sound Interpolation active? true/false
  188.     Boolean                    MicroDelay;                            // Micro delay active? Used only in DeluxeStereoOutPut outPutMode.
  189.     long                    MicroDelaySize;                        // Micro delay duration (in ms, max 1 sec = 1000 ms)
  190.     Boolean                    surround;                            // Surround effect active? true/false
  191. };
  192. typedef struct MADDriverSettings MADDriverSettings;
  193.  
  194. /********************                        ***********************/
  195. /***             Informations about Plugs: ThePlug[]                ***/
  196. /********************                        ***********************/
  197.  
  198. struct PlugInfo
  199. {
  200.     Handle        IOPlug;                                            // Plug CODE
  201.     Str63        MenuName;                                        // Plug name
  202.     Str63        AuthorString;                                    // Plug author
  203.     FSSpec        file;                                            // Location of plug file
  204.     OSType        type;                                            // OSType of file support
  205.     OSType        mode;                                            // Mode support : Import +/ Export
  206.     Boolean        hasPPCCode;                                        // Is Plug FAT?
  207. };
  208. typedef struct PlugInfo PlugInfo;
  209.  
  210.  
  211. /********************                        ***********************/
  212. /***         Global structure : PlayerPRO variables                ***/
  213. /********************                        ***********************/
  214.  
  215. struct MADDriverRec
  216. {
  217.     long                    IDType;                                // IDType = 'MADD' -- READ ONLY --
  218.  
  219.     /**********************/
  220.     /** Public variables **/
  221.     /**********************/
  222.  
  223.     MADDriverSettings        DriverSettings;                        // Driver SetUp -- READ ONLY --
  224.  
  225.     /**  Current music in memory, loaded with RLoadMusic() by example **/
  226.  
  227.     MADSpec                    *header;                            // MAD Header  -- READ ONLY --
  228.     PatData                    *partition[ MAXPATTERN];            // Patterns    -- READ ONLY --
  229.     sData                    *(sample[ MAXINSTRU][ MAXSAMPLE]);    // Instruments -- READ ONLY --
  230.     
  231.     /**  Drivers variables **/
  232.     
  233.     Channel                    chan[ MAXTRACK];                    // Current driver channels -- READ ONLY --
  234.     Boolean                    musicEnd;                            // Is music playing finished? -- READ ONLY --
  235.     short                    Tube[ MAXTRACK];                    // Used in 'Tracks View' Window - View menu 
  236.     short                    PartitionReader;                    // Current position in pattern (0...64)
  237.     short                    Pat;                                // Current ID Pattern, see 'Patterns list'
  238.     short                    PL;                                    // Current position in partition, see 'Partition list'
  239.     long                    VolExt[ MAXTRACK];                    // Volumes settings, see 'Adaptators' window
  240.     short                    speed;                                // Current speed, see speed Effect
  241.     short                    finespeed;                            // Current finespeed, see speed Effect
  242.     short                    InstruTube[ MAXINSTRU];                // Used in 'Instrument View' Window - View menu
  243.     short                    VExt;                                // External music speed, see 'Adaptators' window
  244.     short                    FreqExt;                            // External music pitch, see 'Adaptators' window
  245.     Boolean                    Reading;                            // Reading indicator
  246.     short                    LeftRight[ MAXTRACK];                // Left/Right % for Deluxe Driver
  247.  
  248.     /** Plugs Import/Export variables **/
  249.  
  250.     PlugInfo                 *ThePlug;                            // Pointers on plugs code & infos
  251.     short                    TotalPlug;                            // no of Plugs in pointer ThePlug
  252.  
  253.  
  254.     /** Private variables - Not documented **/
  255.     /* DO NOT MODIFY OR USE these variables */
  256.  
  257.     long                    MIN_PITCH, MAX_PITCH;
  258.     short                    smallcounter, trackDiv;
  259.     long                    FREQBASE;
  260.     short                    InstruActif[ MAXINSTRU];
  261.     Ptr                        SysHeapPtr, Vol, IntDataPtr, OscilloWavePtr;
  262.     Boolean                    JumpToNextPattern, endPattern;
  263.     long                    ASCBUFFER;
  264.     long                    BufSize;
  265.     long                    VSYNC, BufCounter, BytesToGenerate;
  266.     short                    vibrato_table[ 64];
  267.     short                    MIDIPortRefNum;
  268.     SndChannelPtr             pseudoChanAWAC;
  269.     short                    InstuNoOld[ MAXTRACK];
  270.     short                    NoteOld[ MAXTRACK];
  271.     short                    VelocityOld[ MAXTRACK];
  272.     SndDoubleBufferHeader     TheHeader;
  273.     SndChannelPtr             MusicChannelPP;
  274.     Ptr                        OverShoot;
  275.     long                    *DASCBuffer;
  276.     short                    *DASCBuffer8;
  277.     VBLTask                    VBL;
  278.     long                    VBLA5;
  279.     long                    mytab[ 12];
  280.     long                    MDelay;
  281. };
  282. typedef struct MADDriverRec MADDriverRec;
  283.  
  284. extern    MADDriverRec        *MADDriver;
  285.  
  286. /********************                        ***********************/
  287. /***                        EFFECTS ID                            ***/
  288. /********************                        ***********************/
  289.  
  290. enum {
  291.         arpeggioE         = 0,    //    0x00
  292.         downslideE         = 1,    //    0x01
  293.         upslideE         = 2,    //    0x02
  294.         portamentoE     = 3,    //    0x03
  295.         vibratoE         = 4,    //    0x04
  296.         portaslideE     = 5,    //    0x05
  297.         vibratoslideE    = 6,    //    0x06
  298.         nothingE         = 7,    //    0x07
  299.         offsetE         = 9,    //    0x08
  300.         slidevolE         = 10,    //    0x0A
  301.         fastskipE         = 11,    //    0x0B
  302.         volumeE         = 12,    //    0x0C
  303.         skipE             = 13,    //    0x0D
  304.         extendedE         = 14,    //    0x0E
  305.         speedE             = 15    //    0x0F
  306.     };
  307.  
  308. /********************                        ***********************/
  309. /***                        FUNCTIONS                            ***/
  310. /********************                        ***********************/
  311.  
  312.  
  313. #ifdef __cplusplus
  314. extern "C" {
  315. #endif
  316.  
  317. OSErr    MADInitLibrary( Str255 PlugsFolderName);                    // Library initialisation, you have to CALL this function if you want to use other functions & variables
  318. OSErr    MADDisposeLibrary( void);                                    // Close Library, close music, close driver, free all memory
  319.  
  320. void    MADGetBestDriver( MADDriverSettings    *DriverInitParam);        // Found and identify the current Mac sound hardware and fill DriverInitParam
  321. OSErr    MADCreateDriver( MADDriverSettings    *DriverInitParam);        // Music Driver initialization and memory allocation
  322. OSErr    MADDisposeDriver();                                            // Dispose the music driver, use it after RInitMusic()
  323.  
  324. OSErr    MADPlay( void);                                                // Play the current music
  325. OSErr    MADStop( void);                                                // Stop the current music
  326. OSErr    MADReset( void);                                            // Reset the current music at the start position
  327.  
  328. OSErr    MADLoadMusicFile( Str255 fName);                            // Load a MAD File in the current directory
  329. OSErr    MADLoadMusicRsrc( OSType IDName, short IDNo);                // Load a MAD Rsrc into memory
  330. OSErr    MADLoadMusicPtr( Ptr myPtr);                                // Load a MAD Ptr into memory, you can DisposPtr your Ptr after this call
  331. OSErr    MADLoadMusicPartition( MADPartition *aPartition);            // Load a MAD partition into memory
  332. OSErr    MADImportMusicFile( OSType plugType, Str255 fName);            // Import a non-MAD music file with plugs
  333. OSErr    MADMusicIdentify( OSType *type, Str255 fName);                // Identify what kind of music format is fName file.
  334. Boolean    MADPlugAvailable( OSType type);                                // Is plug 'type' available?
  335.  
  336. OSErr    MADDisposeMusic(void);                                        // Dispose the current music, use it after RLoadMusic(), RLoadMusicRsrc(), RInstallMADF()
  337.  
  338. void    MADChangeTracks( short);                                    // Change current tracks number of the music driver
  339. void    MADCleanDriver();                                            // Clean the driver : stop playing sounds
  340. Cmd*    GetMADCommand(    short        position,                        // Extract a Command from a PatData structure
  341.                         short        channel,
  342.                         PatData*    aPatData);
  343.  
  344. OSErr    MADPlaySndHandle(     Handle sound,                            // Handle to a 'snd ' handle, by ex: GetResource('snd ', 128);
  345.                             long chan,                                // channel ID on which to play sound
  346.                             long note);                                // note: 0 to NUMBER_NOTES or 0xFF: play sound at his normal sampleRate Khz
  347.  
  348. OSErr    MADPlaySoundData(    Ptr                soundPtr,                // Sound Pointer to data
  349.                             long            size,                    // Sound size in bytes
  350.                             long            channel,                // channel ID on which to play sound
  351.                             long            note,                    // note: 0 to NUMBER_NOTES or 0xFF: play sound at 22 Khz
  352.                             long            amplitude,                // 8 or 16 bits
  353.                             long            loopBeg,                // loop beginning
  354.                             long            loopSize,                // loop size in bytes
  355.                             unsigned long    rate);                    // sample rate of the sound data, by ex: rate22khz
  356.  
  357. #ifdef __cplusplus
  358. }
  359. #endif
  360.  
  361. /********************                        ***********************/
  362. //
  363. //    Player PRO 4.5x -- Plug IMPORT / EXPORT Definition
  364. //
  365. //    Version 2.0
  366. //
  367. //    To use with PlayerPRO for Think C & CodeWarrior
  368. //
  369. //    Antoine ROSSET
  370. //    16 Tranchees
  371. //    1206 GENEVA
  372. //    SWITZERLAND
  373. //    
  374. //    FAX:            (+41 22) 346 11 97
  375. //    Compuserve:        100277,164
  376. //    Internet:         rosset@dial.eunet.ch
  377. //
  378. //    Your main function have to be in this form:
  379. //    OSErr main( OSType order, FSSpec *AlienFileFSSpec, MADPartition *MadFile, PPInfoRec *info);
  380. //
  381. //    Actual plug have to support these orders:
  382. //
  383. //    order: 'TEST':    check the AlienFile to see if your Plug really support it.
  384. //    order: 'IMPT':    convert the AlienFile into a MADPartition. You have to allocate MADPartition.
  385. //    order: 'INFO':    Fill PPInfoRec structure.
  386. //    order: 'EXPT':    Convert the MADPartition into AlienFile. You have to allocate AlienFile.
  387. //                Don't delete the MADPartition Structure after conversion !!
  388. //
  389. //    An IMPORT plug have to support these orders: 'TEST', 'IMPT', 'INFO'
  390. //    An EXPORT plug have to support these orders: 'EXPT'
  391. //     An IMPORT/EXPORT plug have to support these orders: 'TEST', 'IMPT', 'INFO', 'EXPT'
  392. //
  393. //    About Resources:
  394. //
  395. //    Your Plug should have: Creator: 'SNPL', Type: 'IMPL'
  396. //
  397. //    Your Plug have to have these resources:
  398. //
  399. //    - One segment CODE 1000 with 68k Code
  400. //    - One segment PPCC 1000 with PPC Code (OPTIONAL: if PlayerPRO in PPC cannot find it, it will use the CODE 1000 resource)
  401. //    - One STR# resource :
  402. //
  403. //        1 string: which kind of files your plug support (OSType value!!!) By example: 'STrk', '669 ', etc...
  404. //        2 string: what does your Plug: EXPL : only Export files, IMPL : only Import Files, EXIM : import AND export.
  405. //        3 string: string that will be used in Import and Export menu of PlayerPRO
  406. //        4 string: Copyright string of this plug.
  407. //
  408. /********************                        ***********************/
  409.  
  410. struct PPInfoRec
  411. {
  412.     Str63        internalFileName;
  413.     Str63        formatDescription;
  414.     
  415.     long        totalPatterns;
  416.     long        partitionLength;
  417.     
  418.     short        totalTracks;
  419.     short        totalInstruments;
  420.     
  421.     OSType        signature;
  422.     
  423.     long        fileSize;
  424.     
  425. };
  426. typedef struct PPInfoRec PPInfoRec;
  427.  
  428. #if defined(powerc) || defined (__powerc)
  429. #pragma options align=reset
  430. #else
  431. #if !defined(THINK_C)
  432. #pragma options align=reset
  433. #endif
  434. #endif
  435. #endif